
require('../css/commonCss/normalize.css')
require('../css/commonCss/basic.css')
require('../css/commonCss/property.css')
require('../css/commonCss/reset.css')
require('../liabs/iconfont/iconfont.css')
require('../css/commonCss/footer.less')
require('../css/courseDetails.less')

const axios = require('axios')

document.addEventListener('DOMContentLoaded', function () {

    axios.get('http://139.9.177.51:8099/sports/courseDetail?id=' + sessionStorage.cid).then(function (res) {
        let data = res.data.data;
        console.log(data)
        document.querySelector('#calorie').textContent = data.calorie
        document.querySelector('#time').textContent = data.time;
        document.querySelector('#peoplenum').textContent = data.peoplenum;
        document.querySelector('#instrument').textContent = data.instrument;
        document.querySelector('#frequency').textContent = data.frequency;
        document.querySelector('#video').src ='http://139.9.177.51:8099'+data.fragments[0].videoUrl
        //将视频存储到会话存储
        sessionStorage.videoUrl = JSON.stringify(data.fragments)
    })

    //点击返回上一个页面
    document.querySelector('#return').addEventListener('click', function () {
        history.go(-1)
    })

    let video = document.querySelector('#video')
    //点击开始播放视频
    document.querySelector('#beginPlay').addEventListener('click', function () {
        video.controls = true;
        video.play()
        video.style.display = 'block'
        topIcon.style.display = 'none'
    })

    document.querySelector('#video').addEventListener('pause',function(){
        topIcon.style.display ='block';
        video.controls = 'true'
    })

    document.querySelector('#beginBtn').addEventListener('click',function(){
        location.href = './train.html'
    })
})